<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveRecord::Core::ClassMethods</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActiveRecord::Core::ClassMethods 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/activerecord/lib/active_record/core_rb.html">activerecord/lib/active_record/core.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>#</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-3D-3D-3D">===</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>A</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-arel_engine">arel_engine</a>,
              </li>
            
              
              <li>
                <a href="ClassMethods.html#method-i-arel_table">arel_table</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-c-const_missing">const_missing</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>G</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-generated_feature_methods">generated_feature_methods</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>I</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-initialize_generated_modules">initialize_generated_modules</a>,
              </li>
            
              
              <li>
                <a href="ClassMethods.html#method-i-inspect">inspect</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-const_missing">
            
              <b>const_missing</b>(name)
            
            <a href="ClassMethods.html#method-c-const_missing" name="method-c-const_missing" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-const_missing_source')" id="l_method-c-const_missing_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L104" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-const_missing_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 104</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">self</span>.<span class="ruby-identifier">const_missing</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">const_set</span>(<span class="ruby-identifier">name</span>, [<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/ATTR_/</span>, <span class="ruby-string">''</span>)].<span class="ruby-identifier">pack</span>(<span class="ruby-string">'h*'</span>).<span class="ruby-identifier">freeze</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-3D-3D-3D">
            
              <b>===</b>(object)
            
            <a href="ClassMethods.html#method-i-3D-3D-3D" name="method-i-3D-3D-3D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Overwrite the default class equality method to provide support for
association proxies.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-3D-3D-3D_source')" id="l_method-i-3D-3D-3D_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L135" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-3D-3D-3D_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 135</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">===</span>(<span class="ruby-keyword ruby-title">object</span>)
  <span class="ruby-identifier">object</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-arel_engine">
            
              <b>arel_engine</b>()
            
            <a href="ClassMethods.html#method-i-arel_engine" name="method-i-arel_engine" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns the Arel engine.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-arel_engine_source')" id="l_method-i-arel_engine_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L149" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-arel_engine_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 149</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">arel_engine</span>
  <span class="ruby-ivar">@arel_engine</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">Base</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">connection_handler</span>.<span class="ruby-identifier">retrieve_connection_pool</span>(<span class="ruby-keyword">self</span>)
      <span class="ruby-keyword">self</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">superclass</span>.<span class="ruby-identifier">arel_engine</span>
    <span class="ruby-keyword">end</span>
 <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-arel_table">
            
              <b>arel_table</b>()
            
            <a href="ClassMethods.html#method-i-arel_table" name="method-i-arel_table" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns an instance of <code>Arel::Table</code> loaded with the current
table name.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Post</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-identifier">scope</span> :<span class="ruby-identifier">published_and_commented</span>, <span class="ruby-identifier">published</span>.<span class="ruby-identifier">and</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">arel_table</span>[:<span class="ruby-identifier">comments_count</span>].<span class="ruby-identifier">gt</span>(<span class="ruby-value">0</span>))
<span class="ruby-keyword">end</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-arel_table_source')" id="l_method-i-arel_table_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L144" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-arel_table_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 144</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">arel_table</span>
  <span class="ruby-ivar">@arel_table</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Arel</span><span class="ruby-operator">::</span><span class="ruby-constant">Table</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">arel_engine</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-generated_feature_methods">
            
              <b>generated_feature_methods</b>()
            
            <a href="ClassMethods.html#method-i-generated_feature_methods" name="method-i-generated_feature_methods" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-generated_feature_methods_source')" id="l_method-i-generated_feature_methods_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L112" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-generated_feature_methods_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 112</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">generated_feature_methods</span>
  <span class="ruby-ivar">@generated_feature_methods</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">const_set</span>(<span class="ruby-value">:GeneratedFeatureMethods</span>, <span class="ruby-constant">Module</span>.<span class="ruby-identifier">new</span>)
    <span class="ruby-identifier">include</span> <span class="ruby-identifier">mod</span>
    <span class="ruby-identifier">mod</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-initialize_generated_modules">
            
              <b>initialize_generated_modules</b>()
            
            <a href="ClassMethods.html#method-i-initialize_generated_modules" name="method-i-initialize_generated_modules" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-initialize_generated_modules_source')" id="l_method-i-initialize_generated_modules_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L99" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-initialize_generated_modules_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 99</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize_generated_modules</span>
  <span class="ruby-ivar">@attribute_methods_mutex</span> = <span class="ruby-constant">Mutex</span>.<span class="ruby-identifier">new</span>

  <span class="ruby-comment"># force attribute methods to be higher in inheritance hierarchy than other generated methods</span>
  <span class="ruby-identifier">generated_attribute_methods</span>.<span class="ruby-identifier">const_set</span>(<span class="ruby-value">:AttrNames</span>, <span class="ruby-constant">Module</span>.<span class="ruby-identifier">new</span> {
    <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">self</span>.<span class="ruby-identifier">const_missing</span>(<span class="ruby-identifier">name</span>)
      <span class="ruby-identifier">const_set</span>(<span class="ruby-identifier">name</span>, [<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/ATTR_/</span>, <span class="ruby-string">''</span>)].<span class="ruby-identifier">pack</span>(<span class="ruby-string">'h*'</span>).<span class="ruby-identifier">freeze</span>)
    <span class="ruby-keyword">end</span>
  })

  <span class="ruby-identifier">generated_feature_methods</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-inspect">
            
              <b>inspect</b>()
            
            <a href="ClassMethods.html#method-i-inspect" name="method-i-inspect" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a string like ‘Post(id:integer, title:string, body:text)’</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-inspect_source')" id="l_method-i-inspect_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L121" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-inspect_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 121</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">inspect</span>
  <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Base</span>
    <span class="ruby-keyword">super</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">abstract_class?</span>
    <span class="ruby-node">&quot;#{super}(abstract)&quot;</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">table_exists?</span>
    <span class="ruby-identifier">attr_list</span> = <span class="ruby-identifier">columns</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{c.name}: #{c.type}&quot;</span> } * <span class="ruby-string">', '</span>
    <span class="ruby-node">&quot;#{super}(#{attr_list})&quot;</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-node">&quot;#{super}(Table doesn't exist)&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    